<template>
  <div class="total-box">
    <!-- 搜索 -->
    <div class="section1">
      <div class="section1-1">
        <i class="el-icon-search" @click="sousuo"></i>
        <input
          type="text"
          placeholder="请输入用户名查询"
          v-model="filterText"
          class="input1"
          @input="textNone1($event)"
          @keyup.enter="textNone($event)"
        />
      </div>
    </div>
    <!-- 表格数据 -->
    <div>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="recharge_id" label="充值记录编号"></el-table-column>
        <el-table-column prop="user.user_name" label="用户名"></el-table-column>
        <el-table-column
          prop="recharge_money"
          label="充值金额"
        ></el-table-column>
        <el-table-column
          prop="recharge_time"
          label="充值时间"
        ></el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="paging">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage"
        :page-size="pageNum"
        layout="prev, pager, next, jumper"
        :total="drugList"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import http from '../api';
export default {
  data() {
    return {
      filterText: '',
      tableData: [],
      currentPage: 1,
      pageNum: 6,
      drugList: 0,
    };
  },
  computed: {},
  mounted() {
    this.getData();
  },
  methods: {
    textNone(e) {
      console.log(e);
      this.getData(this.value);
    },
    textNone1(e) {
      if (e.target.value == '') {
        this.currentPage=1;
        this.getData(this.value);
      }
    },
    modify(row, index) {
      // this.$refs.modifyinfo.open(row);
      //返回当前对象
      console.log(row, index);
    },
    sousuo() {
      this.getData();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      console.log(val);
      this.getData();
    },
    //获取数据
    getData() {
      http
        .userRechargeRecord({
          params: {
            pages: this.currentPage,
            pageSize: 6,
            name: this.filterText,
          },
        })
        .then((r) => {
          console.log(r);
          this.drugList = r.data.counts;
          this.tableData = r.data.data;
        });
    },
  },
};
</script>
<style scoped>
.section1{
  margin-bottom: 40px;
}
.section1-1 {
  width: 190px;
  height: 40px;
  border: 1px solid gainsboro;
  display: flex;
  justify-content: center;
  background-color: white;
  align-items: center;
}
.input1 {
  width: 150px;
  height: 30px;
  border: none;
  margin-left: 10px;
  outline: none;
}
.paging {
  margin-top: 30px;
  margin-left: 30%;
  position: absolute;
  left: 190px;
  bottom: 60px;
}

.el-pagination >>> .el-pagination__jump {
  font-size: 17px;
}
.el-pagination >>> .el-icon {
  font-size: 17px;
}
.el-pagination >>> .number {
  font-size: 17px;
  width: 60px;
}
.total-box {
  background-color: white;
  padding-top: 30px;
  margin-top: 10px;
  height: 600px;
}
</style>